package com.chief.hadoop.mr.partition;


import com.chief.hadoop.mr.writable.FlowBean;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Partitioner;


public class FlowPartitioner extends Partitioner<Text, FlowBean> {

    @Override
    public int getPartition(Text text, FlowBean flowBean, int i) {
        String phone = text.toString();
        String prefix = phone.substring(0, 3);
        if ("134".equals(prefix)) {
            return 0;
        } else if ("135".equals(prefix)) {
            return 1;
        } else if ("136".equals(prefix)) {
            return 2;
        } else if ("137".equals(prefix)) {
            return 3;
        }
        return 4;
    }
}
